package com.example.aggregatedemo.arrary.a05mySet;

public class Student_Tree_2 implements Comparable<Student_Tree_2>{
    private String name;
    private Integer age;

    private Integer Chinese;

    private Integer English;
    private Integer Math;

    public Student_Tree_2(String name, Integer age, Integer chinese, Integer english, Integer math) {
        this.name = name;
        this.age = age;
        Chinese = chinese;
        English = english;
        Math = math;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    public Integer getChinese() {
        return Chinese;
    }

    @Override
    public String toString() {
        return "Student_Tree_2{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", Chinese=" + Chinese +
                ", English=" + English +
                ", Math=" + Math +
                ", AllSum=" + (Chinese+English+Math) +
                '}';
    }

    public void setChinese(Integer chinese) {
        Chinese = chinese;
    }

    public Integer getEnglish() {
        return English;
    }

    public void setEnglish(Integer english) {
        English = english;
    }

    public Integer getMath() {
        return Math;
    }

    public void setMath(Integer math) {
        Math = math;
    }

    @Override
    public int compareTo(Student_Tree_2 o) {
        int sum1=this.getChinese()+getEnglish()+getMath();
        int sum2=o.getChinese()+getEnglish()+getMath();
        int i=sum1-sum2;

        i=i==0?this.getChinese()-o.getChinese():i;
        i=i==0?this.getMath()-o.getMath():i;
//        i=i==0?this.getEnglish()-o.getEnglish():i;  //总分一样，前两个一样
        i=i==0?this.getAge()-o.getAge():i;
        i=i==0?this.getName().compareTo(o.getName()):i; //按照默认字母排

        return i;
    }
}
